package com.service.impl;

import com.dao.ProductTypeDao;
import com.dao.impl.ProductTypeDaoImpl;
import com.pojo.PageBean;
import com.pojo.ProductType;
import com.service.ProductTypeService;

import java.util.List;

public class ProductTypeServiceImpl implements ProductTypeService {
    private ProductTypeDao dao= new ProductTypeDaoImpl();

    @Override
    public ProductType findByID(String id) {
        return dao.findByID(id);
    }

    @Override
    public PageBean<ProductType> findAll(int limit, int current) {
        int count = dao.selectCount();
        List<ProductType> list = dao.findAll((current - 1) * limit, limit);
        PageBean<ProductType> pageBean = new PageBean<>();
        pageBean.setData(list);
        pageBean.setCurrent(current);
        pageBean.setTotal(count);
        return pageBean;
    }

    @Override
    public boolean deletePT(String id) {
        return dao.deletePT(id)>0;
    }

    @Override
    public boolean updatePT(ProductType productType) {
        return dao.updatePT(productType)>0;
    }

    @Override
    public boolean addPT(ProductType productType) {
        return dao.addPT(productType)>0;
    }

    @Override
    public List<ProductType> findAll() {
        return dao.findAll();
    }

}
